#ifndef VIDEOCAPTURE_AVTUNIAPI_H
#define VIDEOCAPTURE_AVTUNIAPI_H
#ifndef NO_AVT_UNIAPI

#include "UniAPI/include/UniControl.h"
#include "UniAPI/include/UniTransform.h"
#include <opencv/cxcore.h>
#include <string>
#include <vector>
#include "CameraInterfaceBase.h"

using namespace std;

class AvtUniAPI : public CameraInterface {
public:
	AvtUniAPI();
	~AvtUniAPI();
	int probeCam(unsigned long manualIPaddress = (130 << 24) | (123 << 16) | (248 << 8) | (16) );
	bool getCamId(int index, unsigned long &camId, std::string *camName = NULL);
	bool openCam(unsigned long camId);
	bool initCam();
	bool getCamProperties(unsigned long propId, unsigned long &value);
	bool setCamProperties(unsigned long propId, unsigned long value);
	bool setImageSize(unsigned int width = 640, unsigned int height = 480, unsigned int bytesPerChannel = 1, unsigned int channels = 3);
	IplImage* grabRawImage();
	bool closeCam();
private:
	UINT32_TYPE Intelaced;
	void deInteraceImage(char *dataSource, char *dataDist, int width, int height, int srcWidthStep, int dstWidthStep);
	std::vector<int> camList;
    UNI_RETURN_TYPE Result;         // Uni Api function returns
	void *ImageBuffer;
	S_UNI_TRANSPORT_FORMAT_INFO formatInfo;
	S_UNI_IMAGE pImage;
	UINT32_TYPE width, height;
    UINT32_TYPE                 cnt;        // max camera number
    std::vector<UINT32_TYPE>    CamIds;    // array for 64 camera ids
	UINT32_TYPE selectedCamId;
	UINT32_TYPE ImageWidth, ImageHeight, ColorCoding, ImageDepth, SizeInBytes;
	UINT32_TYPE BayerPattern, Interface;
	std::string GetColorString( UINT32_TYPE ColorCode);
	//UINT32_TYPE IsColor;
	//int countCameras();
	//static
	//bool capture_init();
	//void capture_image();
	//static
	//void capture_exit();
	//bool ListCameras(int camNum);
	//void selectCamera(int camNum);
	//IplImage*   rgbImage;// = NULL;
	//bool	initialised;
	//int numCamera;
//std::vector<AvtUniCamInfoSheet> CamInfos;
	//std::vector<std::vector<string > > CamInfoStringSet;
	//std::vector<std::vector<UINT32_TYPE > > CamInfoValueSet;
	//std::vector<string> CamNames;
	
	//bool bufferLocked;

	//int selectedCam;
};


/*
struct AvtUniCamInfoSheet {
	string s_E_CAMINFO_MODEL; //  model info 
 string s_E_CAMINFO_VENDOR;//  vendor info 
string s_E_CAMINFO_IIDCVERSION; //  IIDC version info. 
string s_E_CAMINFO_SN; //  serial number 
string s_E_CAMINFO_ORDERID; //  order ID 
string s_E_CAMINFO_MCVERSION; //  Micro controller version info. 
string s_E_CAMINFO_FPGAVERSION; //  FPGA version info. 
string s_E_CAMINFO_CUSTOMERKEY; //  customer key info 
string s_E_CAMINFO_MAXWIDTH; //  maximum width of the camera 
string s_E_CAMINFO_MAXHEIGHT; //  maximum height of the camera 
string s_E_CAMINFO_MAXDEPTH; //  maximum bit depth of the camera 
string s_E_CAMINFO_COLORCAMERA; //  Is this a color camera? 
string s_E_CAMINFO_BAYERPATTERN; //  Current Bayer pattern for the current image settings (see E_UNI_BAYER_PATTERN) 
string s_E_CAMINFO_INTERLACED; //  Is this an interlaced camera? 
string s_E_CAMINFO_SISTYPE; //  type of SIS supported by the camera 
string s_E_CAMINFO_INTERFACETYPE; //  type of camera interface (see E_UNI_INTERFACE) 
string s_E_CAMINFO_IMAGE_ENDIANNESS; //  endianness of image data (see E_UNI_ENDIANNESS) 
string s_E_CAMINFO_IMAGE_ALIGNMENT; //  alignment of image data (see E_UNI_ALIGNMENT) 
string s_E_CAMINFO_BUS_LOAD; //  currently configured bus load (in 1/1000)(see UCC_PrepareFreeGrab) 
string s_E_CAMINFO_HOST_IPADDRESS; //  IP address of host currently controlling the camera (GigE cameras only) 
string s_E_CAMINFO_HOST_MACADDRESS; //  MAC address of host currently controlling the camera (GigE cameras only) 
string s_E_CAMINFO_CONTROLLEDEXTERNALLY; //  Is this camera controlled by another application or host? (GigE cameras only) 
string s_E_CAMINFO_READONLY; //  Is this camera opened in read-only mode? (GigE cameras only) 
string s_E_CAMINFO_CAMERA_IPADDRESS; //  camera's IP address (GigE cameras only) 
string s_E_CAMINFO_CAMERA_MACADDRESS; //  camera's MAC address (GigE cameras only) 
string s_E_CAMINFO_RECEIVED_PACKETS; //  number of received packets with image data (GigE cameras only) 
string s_E_CAMINFO_PACKET_RESEND_REQUESTS; //  number of missing packets requested to the camera for resent (GigE cameras only) 
string s_E_CAMINFO_PACKET_RESEND_RECEIVED; //  number of missing packets resent by the camera and received by the host (GigE cameras only) 
string s_E_CAMINFO_OPEN; //  Is this camera opened? 
string s_E_CAMINFO_CARD_ID; //  
}
*/

#endif
#endif

